# !/usr/bin python3
# encoding: utf-8 -*-
# @file     : home_page.py
# @author   : 沙陌 Matongxue_2
# @Time     : 2023/11/12 9:58
# @Copyright: 北京码同学

from pages.base_page import BuyerBasePage
from pages.buyer.goods_page import GoodsDetailPage
from pages.buyer.login_page import LoginPage
from pages.buyer.person_page import PersonCenterPage


class HomePage(BuyerBasePage):

    # def __init__(self):
    #     super().__init__()
    #     self.page_eles = load_yaml_file(buyer_yaml)[self.__class__.__name__]

    def click_login_link(self):
        ele_info = self.page_eles['登录链接']
        # ele_info = {"name":"登录链接","type":"linktext","value":"登录","timeout":5}
        self.operate.click(ele_info)
        # 当点击后会进入到另外一个页面，那么可以返回该页面对象
        return LoginPage()
    def click_enter_personcenter(self):
        ele_info = self.page_eles['进入个人中心']
        # ele_info = {"name":"进入个人中心","type":"linktext","value":"进入个人中心","timeout":5}
        self.operate.click(ele_info)
        return PersonCenterPage()

    def send_keys_search(self,text):
        ele_info = self.page_eles['搜索输入框']
        self.operate.send_keys(ele_info,text)
        return self
    def click_shop_btn(self):
        ele_info = self.page_eles['搜店铺']
        self.operate.click(ele_info)
        return SearchResultPage()

class SearchResultPage(BuyerBasePage):
    def click_first_goods(self):
        ele_info = self.page_eles['第一个商品']
        self.operate.click(ele_info)
        return GoodsDetailPage()